<script type="text/javascript">
function  deleteZimmer(id , name){
	if (confirm("<?PHP LangText('DeleteMas'); ?>")) {//if yes
	   window.location =document.URL+'&FilegalerieID='+id;
	}
}
function validateOnSubmit(formElem) {
		formElem.submit();
	};
function setFileOption(ch){
	if(ch){
		//alert('on');
		document.getElementById('file').style.display='block';
		document.getElementById('LogoID').style.display='none';
		}else{
			//alert('off');
		document.getElementById('file').style.display='none';
		document.getElementById('LogoID').style.display='block';
	}
};	
</script>
<?php
if (!empty ($_SESSION["CMS_User"]["ID"])) {
	if (!empty ($_GET['FilegalerieID'])) {
		$sql = 'DELETE  FROM filegalerie WHERE ID=' . $_GET['FilegalerieID'];
		mysql_query($sql, $_db_link);
	}
	//print_r($_FILES);
	if ($_POST["Upload"] == 'on') {
		$LogoID = uploadFile();
	} else {
		$LogoID = $_POST["LogoID"];
	}
	if ($_POST && $LogoID) {
		$sql = "insert INTO  filegalerie (FileID,GalerieID) 
												values('" . $LogoID . "','" . $_GET['GalerieID'] . "')";
		$_rd = mysql_query($sql, $_db_link);
	}
	if ($_GET['GalerieID']) {
		$sql = "select * From galerieview WHERE GalerieID={$_GET['GalerieID']}";
		$_rd = mysql_query($sql, $_db_link);
		$str = "";
		if ($_rd) {
			$sw = "row1";
			$str = "<div class='FirmaView'><table class='FirmaList'>
																			<tr class='$sw'>
																			<td><b>" . LangTextOut("ID") . "</b></td>
																			<td><b>" . LangTextOut("Name") . "</b></td>
																			<td><b>" . LangTextOut("Titel") . "</b></td>" .
			"<td><b>" . LangTextOut("Adresse") . "</b></td>" .
			"</tr>";
			while ($daten = mysql_fetch_array($_rd, MYSQL_ASSOC)) {
				if ($sw == "row1") {
					$sw = "row2";
				} else {
					$sw = "row1";
				}
				$str = $str . "<tr class='$sw'>
																											<td>" . $daten["ID"] . "</td>
																											<td>" . $daten["Name"] . "</td>
																											<td>" . $daten["Titel"] . "</td>" .
				"<td>" . $daten["Adresse"] . "</td>" .
				"<td><a  href=\"javascript:deleteZimmer('" . $daten["ID"] . "','" . $daten["Titel"] . "');\"  >" . LangTextOut("Delete") . "</a>" .
				"</td>" .
				"</tr>";
			}
			$str = $str . "</table></div>";
		}
		echo $str;
	}
	$LogoList = "<select name='LogoID' id='LogoID'>";
	getListBox($LogoList, $daten["LogoID"], "files", "WHERE UserID=" . $_SESSION["CMS_User"]["ID"]);
	$LogoList = $LogoList . "</select>";
}
?>
<hr>
<div style="width:100%;background-color:#F1EEF3;margin:0px"> 
	<table class="tableEdit">
	<tr>
	<td class="lableEdit"><?PHP  LangText("LogoID");?>:</td>
	<td class="inputEdit"><input type="checkbox" onchange="setFileOption(this.checked)" id="Upload" name="Upload"/> 
	 <?PHP  LangText("Upload-Datei");?> 
	  <?PHP echo $LogoList; ?> <input type="file" id="file" name="file" style="display:none" /></td>
	<td class="validateEdit"></td>
	</tr>

	
	<tr>
	<td class="lableEdit"></td>
	<td class="inputEdit">
	<input type="button"  onclick="validateOnSubmit(this.form);" class="BootenLink" value='<?PHP if($AbteilungID!=NULL && $AbteilungID != 0 ){LangText("Bearbeiten");}else{ LangText("Himzufugen");}?>' />
	<input type="button"  onclick="window.location='index.php?tag=<?PHP echo $_GET['tag']; ?>'" class="BootenLink" value='<?PHP LangText("Abbrechen");?>' /></td>
	<td class="validateEdit"></td>
	</tr>
	</table>
	</div>

